<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Grammar classes reference &mdash; Dragonfly v0.6.4rc3 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '',
          VERSION:     '0.6.4rc3',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="contents" title="Global table of contents" href="contents.html" />
    <link rel="index" title="Global index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Dragonfly v0.6.4rc3 documentation" href="index.html" />
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li><a href="index.html">Dragonfly v0.6.4rc3 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="grammar-classes-reference">
<span id="refgrammarclasses"></span><h1>Grammar classes reference<a class="headerlink" href="#grammar-classes-reference" title="Permalink to this headline">¶</a></h1>
<p>This section describes the following classes:</p>
<blockquote>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">Grammar</span></tt> &#8211; the base grammar class.</li>
<li><tt class="docutils literal"><span class="pre">ConnectionGrammar</span></tt> &#8211; a derived class which makes it very
easy to maintain a COM connections while the target
application is  in the foreground.</li>
</ul>
</blockquote>
<div class="section" id="grammar-class">
<h2>Grammar class<a class="headerlink" href="#grammar-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="dragonfly.grammar.grammar_base.Grammar">
<!--[dragonfly.grammar.grammar_base.Grammar]-->class <tt class="descname">Grammar</tt><big>(</big><em>name</em>, <em>description=None</em>, <em>context=None</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar" title="Permalink to this definition">¶</a></dt>
<dd><p>Grammar class for managing a set of rules.</p>
<p>This base grammar class takes care of the communication 
between Dragonfly&#8217;s object model and the backend speech 
recognition engine.  This includes compiling rules and 
elements, loading them, activating and deactivating 
them, and unloading them.  It may, depending on the 
engine, also include receiving recognition results and 
dispatching them to the appropriate rule.</p>
<blockquote>
<ul class="simple">
<li><em>name</em> &#8211; name of this grammar</li>
<li><em>description</em> (str, default: None) &#8211;
description for this grammar</li>
<li><em>context</em> (Context, default: None) &#8211;
context within which to be active.  If <em>None</em>, the grammar will
always be active.</li>
</ul>
</blockquote>
<dl class="attribute">
<dt id="dragonfly.grammar.grammar_base.Grammar.name">
<!--[dragonfly.grammar.grammar_base.Grammar.name]--><tt class="descname">name</tt><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.name" title="Permalink to this definition">¶</a></dt>
<dd>A grammar&#8217;s name.</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.grammar_base.Grammar.engine">
<!--[dragonfly.grammar.grammar_base.Grammar.engine]--><tt class="descname">engine</tt><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.engine" title="Permalink to this definition">¶</a></dt>
<dd>A grammar&#8217;s SR engine.</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.grammar_base.Grammar.rules">
<!--[dragonfly.grammar.grammar_base.Grammar.rules]--><tt class="descname">rules</tt><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.rules" title="Permalink to this definition">¶</a></dt>
<dd>List of a grammar&#8217;s rules.</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.grammar_base.Grammar.lists">
<!--[dragonfly.grammar.grammar_base.Grammar.lists]--><tt class="descname">lists</tt><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.lists" title="Permalink to this definition">¶</a></dt>
<dd>List of a grammar&#8217;s lists.</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.load">
<!--[dragonfly.grammar.grammar_base.Grammar.load]--><tt class="descname">load</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.load" title="Permalink to this definition">¶</a></dt>
<dd>Load this grammar into its SR engine.</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.unload">
<!--[dragonfly.grammar.grammar_base.Grammar.unload]--><tt class="descname">unload</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.unload" title="Permalink to this definition">¶</a></dt>
<dd>Unload this grammar from its SR engine.</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.grammar_base.Grammar.loaded">
<!--[dragonfly.grammar.grammar_base.Grammar.loaded]--><tt class="descname">loaded</tt><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.loaded" title="Permalink to this definition">¶</a></dt>
<dd>Whether a grammar is loaded into its SR engine or not.</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.enable">
<!--[dragonfly.grammar.grammar_base.Grammar.enable]--><tt class="descname">enable</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.enable" title="Permalink to this definition">¶</a></dt>
<dd>Enable this grammar so that it is active to receive 
recognitions.</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.disable">
<!--[dragonfly.grammar.grammar_base.Grammar.disable]--><tt class="descname">disable</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.disable" title="Permalink to this definition">¶</a></dt>
<dd>Disable this grammar so that it is not active to 
receive recognitions.</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.grammar_base.Grammar.enabled">
<!--[dragonfly.grammar.grammar_base.Grammar.enabled]--><tt class="descname">enabled</tt><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.enabled" title="Permalink to this definition">¶</a></dt>
<dd>Whether a grammar is active to receive recognitions or not.</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.process_begin">
<!--[dragonfly.grammar.grammar_base.Grammar.process_begin]--><tt class="descname">process_begin</tt><big>(</big><em>executable</em>, <em>title</em>, <em>handle</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.process_begin" title="Permalink to this definition">¶</a></dt>
<dd><p>Start of phrase callback.</p>
<p>This method is called when the speech recognition 
engine detects that the user has begun to speak a 
phrase.</p>
<dl class="docutils">
<dt>Arguments:</dt>
<dd><ul class="first last simple">
<li><em>executable</em> &#8211; the full path to the module whose 
window is currently in the foreground.</li>
<li><em>title</em> &#8211; window title of the foreground window.</li>
<li><em>handle</em> &#8211; window handle to the foreground window.</li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar._process_begin">
<!--[dragonfly.grammar.grammar_base.Grammar._process_begin]--><tt class="descname">_process_begin</tt><big>(</big><em>executable</em>, <em>title</em>, <em>handle</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar._process_begin" title="Permalink to this definition">¶</a></dt>
<dd><p>Start of phrase callback.</p>
<p><em>This usually the method which should be overridden 
to give derived grammar classes custom behavior.</em></p>
<p>This method is called when the speech recognition 
engine detects that the user has begun to speak a 
phrase.  This method is only called when this 
grammar&#8217;s context does match positively.  It is 
called by the <tt class="docutils literal"><span class="pre">Grammar.process_begin</span></tt> method.</p>
<dl class="docutils">
<dt>Arguments:</dt>
<dd><ul class="first last simple">
<li><em>executable</em> &#8211; the full path to the module whose 
window is currently in the foreground.</li>
<li><em>title</em> &#8211; window title of the foreground window.</li>
<li><em>handle</em> &#8211; window handle to the foreground window.</li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.enter_context">
<!--[dragonfly.grammar.grammar_base.Grammar.enter_context]--><tt class="descname">enter_context</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.enter_context" title="Permalink to this definition">¶</a></dt>
<dd><p>Enter context callback.</p>
<p>This method is called when a phrase-start has been 
detected.  It is only called if this grammar&#8217;s 
context previously did not match but now does
match positively.</p>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_base.Grammar.exit_context">
<!--[dragonfly.grammar.grammar_base.Grammar.exit_context]--><tt class="descname">exit_context</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_base.Grammar.exit_context" title="Permalink to this definition">¶</a></dt>
<dd><p>Exit context callback.</p>
<p>This method is called when a phrase-start has been 
detected.  It is only called if this grammar&#8217;s 
context previously did match but now doesn&#8217;t 
match positively anymore.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="connectiongrammar-class">
<h2>ConnectionGrammar class<a class="headerlink" href="#connectiongrammar-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="dragonfly.grammar.grammar_connection.ConnectionGrammar">
<!--[dragonfly.grammar.grammar_connection.ConnectionGrammar]-->class <tt class="descname">ConnectionGrammar</tt><big>(</big><em>name</em>, <em>description=None</em>, <em>context=None</em>, <em>app_name=None</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_connection.ConnectionGrammar" title="Permalink to this definition">¶</a></dt>
<dd><p>Grammar class for maintaining a COM connection well 
within a given context.  This is useful for controlling 
applications through COM while they are in the 
foreground.  This grammar class will take care of 
dispatching the correct COM interface when the 
application comes to the foreground, and releasing it 
when the application is no longer there.</p>
<blockquote>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">name</span></tt> &#8211; name of this grammar.</li>
<li><tt class="docutils literal"><span class="pre">description</span></tt> &#8211; description for this grammar.</li>
<li><tt class="docutils literal"><span class="pre">context</span></tt> &#8211; context within which to maintain
the COM connection.</li>
<li><tt class="docutils literal"><span class="pre">app_name</span></tt> &#8211; COM name to dispatch.</li>
</ul>
</blockquote>
<dl class="attribute">
<dt id="dragonfly.grammar.grammar_connection.ConnectionGrammar.application">
<!--[dragonfly.grammar.grammar_connection.ConnectionGrammar.application]--><tt class="descname">application</tt><a class="headerlink" href="#dragonfly.grammar.grammar_connection.ConnectionGrammar.application" title="Permalink to this definition">¶</a></dt>
<dd>COM handle to the application.</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_connection.ConnectionGrammar.connection_up">
<!--[dragonfly.grammar.grammar_connection.ConnectionGrammar.connection_up]--><tt class="descname">connection_up</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_connection.ConnectionGrammar.connection_up" title="Permalink to this definition">¶</a></dt>
<dd><p>Method called immediately after entering this 
instance&#8217;s context and successfully setting up its 
connection.</p>
<p>By default this method doesn&#8217;t do anything.
This method should be overridden by derived classes 
if they need to synchronize some internal state with 
the application.  The COM connection is available 
through the <tt class="docutils literal"><span class="pre">self.application</span></tt> attribute.</p>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.grammar_connection.ConnectionGrammar.connection_down">
<!--[dragonfly.grammar.grammar_connection.ConnectionGrammar.connection_down]--><tt class="descname">connection_down</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.grammar_connection.ConnectionGrammar.connection_down" title="Permalink to this definition">¶</a></dt>
<dd><p>Method called immediately after exiting this 
instance&#8217;s context and disconnecting from the 
application.</p>
<p>By default this method doesn&#8217;t do anything.
This method should be overridden by derived classes 
if they need to clean up after disconnection.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3>Table Of Contents</h3>
            <ul>
<li><a class="reference external" href="">Grammar classes reference</a><ul>
<li><a class="reference external" href="#grammar-class">Grammar class</a></li>
<li><a class="reference external" href="#connectiongrammar-class">ConnectionGrammar class</a></li>
</ul>
</li>
</ul>

            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/grammarclasses.txt">Show Source</a></li>
            </ul>
            <h3>Quick search</h3>
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li><a href="index.html">Dragonfly v0.6.4rc3 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Christo Butcher.
      Last updated on Feb 01, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>